﻿using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Data.SqlClient;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks;

namespace AuthTemplate.Repository.Interface
{
    public interface IRepository<T> where T : class
    {
        DbContext GetDbContext();
        IQueryable<T> AllIncluding(params Expression<Func<T, object>>[] includeProperties);
        IQueryable<T> All { get; }
        IQueryable<T> GetAll();
        T GetSingle();
        IQueryable<T> FindBy(Expression<Func<T, bool>> predicate);
        void Add(T entity);
        void Delete(T entity);
        /// <summary>
        /// 更新所有列
        /// </summary>
        /// <param name="entity"></param>
        void Edit(T entity);
        /// <summary>
        /// 更新部分列
        /// </summary>
        /// <param name="entity">新的实体对象</param>
        /// <param name="parameters">要更新的字段名List</param>
        void Edit(T entity,params string[] parameters);

        bool DetachExistsEntity(T entity);

        int ExecuteSqlCommand(string sql, Dictionary<string, object> paraDic);

        List<S> SqlQueryList<S>(string sql, Dictionary<string, object> paraDic);

        S SqlQuery<S>(string sql, Dictionary<string, object> paraDic);
    }
}
